;(function (root, factory) {
	if(typeof exports === "object" && typeof module === "object")
		module.exports = factory();
	else if(typeof define === "function" && define.amd)
		define([], factory);
	else if(typeof exports === "object")
		exports["UObject"] = factory();
	else
		root["UObject"] = factory();
})(this, function () {
	"use strict";

	var UObject = function () {};

	UObject.prototype = {

		constructor: UObject,

		/**
		 * 深拷贝
		 */
		deepCopy: function (p, c) {
			c = c || {};
			for (var i in p) {
				if(p.hasOwnProperty(i)) {
					if(typeof p[i] == "object") {
						c[i] = Array.isArray(p[i]) ? [] : {};
						this.deepCopy(p[i], c[i]);
					} else {
						c[i] = p[i];
					}
				}
			}
			return c;
		},

		/**
		 * 在一个对象中查找键名为key键值为value的对象; 若同时存在多个key:value,只返回第一个
		 * @param {String} key - 必选,键名
		 * @param {*} value - 必选,值
		 * @param {Array | Object} target - 必选,目标对象
		 * @return {Object}
		 */
		search: function (key, value, target) {
			var result = {}, k = arguments[0], v = arguments[1], t = arguments[2], i;
			if(typeof t == "object") {
				for (i in t) {
					if(!t.hasOwnProperty(i)) {
						continue;
					}
					if(t[i] && (t[i][k] == v)) {
						result = t[i];
						break;
					}
					if(result[k] == undefined) {
						result = this.search(k,v,t[i]);
					} else {
						break;
					}
				}
			}
			return result;
		}

	};

	return new UObject();
});